Passed
Branch master (1b85f8)
by Pieter Epeüs
19:20 queued 15:41
created

error.spec.js ➔ testWrongInput   A

Complexity

Conditions 3

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 3
1
import TruthTable from '../../src/TruthTable.mjs';
2
import InvalidInputError from '../../src/InvalidInputError';
3
4
const ErrorTestCases = [
5
    {
6
        description: 'test propositions with a null value',
7
        propositions: null,
8
        expectedError: 'propositions isnt a number',
9
    },
10
    {
11
        description: 'test propositions with a string',
12
        propositions: 'not ok',
13
        expectedError: 'propositions isnt a number',
14
    },
15
];
16
17
describe.each(ErrorTestCases)(
18
    'Test totalTrueInputs helper exception test',
19
    ({ description, propositions, expectedError }) => {
20
        it(description, () => {
21
            function testWrongInput() {
22
                TruthTable.create(propositions);
23
            }
24
25
            expect(testWrongInput).toThrowError(new Error(expectedError));
26
            expect(testWrongInput).toThrowError(InvalidInputError);
27
        });
28
    }
29
);
30